﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity.Framework;

using System.Data.Objects;

namespace Business.Operations
{
    public class MacUcretOperation
    {
        private static HPDMASEntities db = new HPDMASEntities();

        public MacUcretOperation()
        {

        }

        public static List<MacUcret> MacUcretGetAll()
        {
            var macUcretListesi = db.MacUcret.ToList();
            return macUcretListesi;
        }

        public static MacUcret MacUcretGetByMacUcretId(int macUcretId)
        {
            var macUcret = (from c in db.MacUcret where c.MacUcretID == macUcretId select c).First();
            return macUcret;
        }

        public static void MacUcretDelete(int macUcretId)
        {
            MacUcret k = (from c in db.MacUcret where c.MacUcretID == macUcretId select c).First();
            db.DeleteObject(k);
            db.SaveChanges();
        }

        public static void MacUcretInsert(MacUcret macUcret)
        {
            db.MacUcret.AddObject(macUcret);
            db.SaveChanges();
        }

        public static int MacUcretIdGetBySezonIdLigIdAndGorevId(int sezonId, int ligId, int macGorevId)
        {
            var macUcretId = db.MacUcret.
                Where(c => c.SezonID == sezonId && c.LigID == ligId && c.MacGorevID == macGorevId).
                Select(c => c.MacUcretID).First();
            return macUcretId;
        }

        public static decimal MacUcretiGetByMacUcretId(int macUcretId)
        {
            var macUcreti = db.MacUcret.
                Where(c => c.MacUcretID == macUcretId).
                Select(c => c.MacUcreti.Value).First();
            return macUcreti;
        }

        public static Decimal YuzdeElliDeplasmanUcretiGetByMacUcretId(int macUcretId)
        {
            var yuzdeElliDeplasmanUcreti = db.MacUcret.Where(c => c.MacUcretID == macUcretId).
            Select(c => c.Yuzde50DeplasmanUcreti).FirstOrDefault();
            return (Decimal)yuzdeElliDeplasmanUcreti;
        }
    }
}
